home *** CD-ROM | disk | FTP | other *** search
- DEFINT A-Z
-
- DECLARE SUB SetColor ()
- DECLARE SUB LOCandCOLOR (Row, Col)
- DECLARE SUB LoyalPrint (S$)
-
- 'You call this subroutine without any arguments to set the colors to whatever
- 'the current screen colors are at current location. If you generally use
- 'LOCATE before every print statement then it makes much more sense to combine
- 'the two as I have done for LOCandCOLOR, thereby obviating the need to use
- 'those silly POS(0) and CSRLIN functions. If you REALLY want to emulate
- 'QPrint, you need to do something like LoyalPrint, silly but effective.
- ' For my money, it makes sense in "most" instances to use the assembly
- 'printing functions from Crescent, MicroHelp or ProBAS but there are
- 'occasions when they are combersome, so I hope these help.
- 'Jonathan Zuck
- 'User Friendly, Inc.
- '202-387-1949
- 'CIS:17401,1305
- 'What follows is a small demonstration of the use of these subs...
-
- CLS
- COLOR 0, 7
- FOR x = 1 TO 8
- PRINT SPACE$(80)
- NEXT x
- COLOR 7, 0
- FOR x = 1 TO 8
- PRINT SPACE$(80)
- NEXT x
- FOR x = 1 TO 8
- FOR y = 1 TO 4
- COLOR 0, 7
- PRINT SPACE$(10);
- COLOR 7, 0
- PRINT SPACE$(10);
- NEXT y
- PRINT
- NEXT x
-
-
- 'using SetColor
-
- LOCATE 4, 10
- SetColor
- PRINT "This should be white on black"
-
- 'using LOCandCOLOR
-
- LOCandCOLOR 11, 10
- PRINT "And this is black on white"
-
- 'using LoyalPrint
-
- LOCATE 18, 7
- LoyalPrint "And THIS should make your eyes screem out loud for mercy!!!!"
- WHILE INKEY$ = "": WEND
-
- SUB LOCandCOLOR (Row, Col)
- LOCATE Row, Col
- Attr = SCREEN(Row, Col, 1) 'By specifying a non-zero value in
- 'in the third position "colorflag"
- 'you get the color "attribute" rather
- 'than the ASCII number of the char
- 'at that position.
-
- Fore = Attr MOD 16 'This is the best method I know to
- 'parse the attribute into its
- 'colors.
- Back = ((Attr - Fore) / 16) MOD 123
- COLOR Fore, Back
- END SUB
-
- SUB LoyalPrint (S$)
- L = LEN(S$)
- Row = CSRLIN
- Col = POS(0)
- FOR C = 1 TO L
- GOSUB SetColors
- PRINT MID$(S$, C, 1);
- NEXT
- PRINT
- EXIT SUB
- SetColors:
- Attr = SCREEN(Row, C + Col - 1, 1)
- Fore = Attr MOD 16
- Back = ((Attr - Fore) / 16) MOD 123
- COLOR Fore, Back
- RETURN
- END SUB
-
- SUB SetColor
- Attr = SCREEN(CSRLIN, POS(0), 1) 'By specifying a non-zero value in
- 'in the third position "colorflag"
- 'you get the color "attribute" rather
- 'than the ASCII number of the char
- 'at that position.
-
- Fore = Attr MOD 16 'This is the best method I know to
- 'parse the attribute into its
- 'colors.
- Back = ((Attr - Fore) / 16) MOD 123
- COLOR Fore, Back
- END SUB
-
-